package kr.pe.johnkim.chattingday.mobile.rest.service;

import kr.pe.johnkim.chattingday.mobile.domain.ChattingDayGatheringMessage;
import kr.pe.johnkim.chattingday.mobile.rest.dao.ChattingDayGatheringMessageDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Chatting Day 채팅방 메시지 관련 Service 메소드들을 구현하는 클래스이다.
 *
 * @author : johnkim <cale9797@gmail.com / Bettersoft Inc,.>
 * @Date : 12. 6. 12
 */
public class ChattingDayGatheringMessageServiceImpl implements ChattingDayGatheringMessageService {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(ChattingDayGatheringMessageServiceImpl.class);

    @Autowired
    private ChattingDayGatheringMessageDao chattingDayGatheringMessageDao = null;

    /**
     * 채팅방에 메시지를 남긴다.
     *
     * @param chattingDayGatheringMessage
     * @return
     */
    @Override
    public boolean registerGatheringMessage(ChattingDayGatheringMessage chattingDayGatheringMessage) {
        logger.info("registerGatheringMessage");

        return chattingDayGatheringMessageDao.registerGatheringMessage(chattingDayGatheringMessage);
    }

    /**
     * 메시지를 비활성화 한다.
     *
     * @param chattingDayGatheringMessage
     * @return
     */
    @Override
    public boolean updateDeactivateGatheringMessage(ChattingDayGatheringMessage chattingDayGatheringMessage) {
        logger.info("updateDeactivateGatheringMessage");

        return chattingDayGatheringMessageDao.updateDeactivateGatheringMessage(chattingDayGatheringMessage);
    }

    /**
     * 채팅방의 모든 메시지를 비활성화 한다.
     * <p/>
     * 방장(채팅방 개설자)일 경우 가능.
     *
     * @param chattingDayGatheringMessage
     * @return
     */
    @Override
    public boolean updateDeactivateAllGatheringMessage(ChattingDayGatheringMessage chattingDayGatheringMessage) {
        logger.info("updateDeactivateAllGatheringMessage");

        return chattingDayGatheringMessageDao.updateDeactivateAllGatheringMessage(chattingDayGatheringMessage);
    }
}
